<?php
include('./adm_header.php');
?>
			<div id="content">
				<h2>Site Configuration</h2>
				<?php
				if (isset($_POST['submit']))
				{
					if (empty($_POST['admin_password']))
					{
						$admin_password = $admin_password;
					}
					else
					{
						$admin_password = md5($_POST['admin_password']);
					}
					$site_title = $_POST['title'];
					$default_page = $_POST['default_page'];
					$default_template = $_POST['default_template'];
					$admin_username = $_POST['admin_username'];
					// Rewrite config.php
					$fh = fopen('../config.php', 'w');
					fwrite($fh, '<?php $site_title = "' . $site_title . '"; $default_page = "' . $default_page . '"; $default_template = "' . $default_template . '"; $admin_username = "' . $admin_username . '"; $admin_password = "' . $admin_password . '"; ?>');
					fclose($fh);
				}
				?>
				<p>Here you can edit site related configurations such as the Default Page, Site Name, Site Template and Admin Username and Password. If you change the template to a template which is not in the "templates" directory, the site will not function correctly.</p>
				<form action="./configuration.php" method="post">
					<strong>Site Title:</strong><br />
					<input type="text" name="title" value="<?php echo $site_title; ?>" style="font-family: Verdana; font-size: 12px; width: 300px;"><br />
					<br />
					<strong>Default Page:</strong><br />
					<input type="text" name="default_page" value="<?php echo $default_page; ?>" style="font-family: Verdana; font-size: 12px; width: 300px;"><br />
					<br />
					<strong>Default Template:</strong><br />
					<input type="text" name="default_template" value="<?php echo $default_template; ?>" style="font-family: Verdana; font-size: 12px; width: 300px;"><br />
					<br />
					<strong>Admin Username:</strong><br />
					<input type="text" name="admin_username" value="<?php echo $admin_username; ?>" style="font-family: Verdana; font-size: 12px; width: 300px;"><br />
					<br />
					<strong>Admin Password:</strong><br />
					<input type="password" name="admin_password" style="font-family: Verdana; font-size: 12px; width: 300px;"><br /><br />
					<input type="submit" name="submit" value="Save Changes">
				</form>
			</div>
		</div>
	</body>
</html>